//accepted 
#include <cstdio>
#include <cstring>
int t, n;
double x;
char s[3];
int main(){
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	scanf("%d", &t);
	
	for(int i =1;i<=t;++i){
		scanf("%lf %s", &x, s);
		if(!strcmp(s, "kg")){
			printf("%d %.4lf lb\n", i, x*2.2046);
		}
		else if(!strcmp(s, "lb")){
			printf("%d %.4lf kg\n", i, x*.4536);
		}
		else if(!strcmp(s, "l")){
			printf("%d %.4lf g\n", i, x*0.2642);
		}
		else if(!strcmp(s, "g")){
			printf("%d %.4lf l\n", i, x*3.7854);
		}
		
	}
	return 0;
}
